

////SQL> select NAME, BYTES from v$sgainfo where NAME = 'Redo Buffers' or NAME = 'Buffer Cache Size' or 
//NAME = 'Java Pool Size' or NAME = 'Shared Pool Size' or NAME= 'Streams Pool Size' or NAME = 'Large Pool Size';

google.load("visualization", "1", {packages: ["corechart"]});
google.setOnLoadCallback(drawChartSGA);

var Redo_Buffers, Buffer_Cache_Size, Java_Pool_Size, Shared_Pool_Size, Large_Pool_Size, Streams_Pool_Size;
function drawChartSGA() {
    $.ajax({
        type: 'POST',
        url: 'SGA_chart.php',
        dataType: 'json',
        async: true,
        data: {
            req: 'sga'
        },
        success: function (data) {
            console.log(data);
            console.log("success =" + data.success);
            console.log("results =" + data.result[1].BYTES);
            console.log("rowCount =" + data.rowCount);
            Redo_Buffers = data.result[0].BYTES;
            Buffer_Cache_Size = data.result[1].BYTES;
            Shared_Pool_Size = data.result[2].BYTES;
            Large_Pool_Size = data.result[3].BYTES;
            Java_Pool_Size = data.result[4].BYTES;
            Streams_Pool_Size = data.result[5].BYTES;
            var arreglo = [Redo_Buffers, Buffer_Cache_Size, Shared_Pool_Size, Large_Pool_Size, Java_Pool_Size, Streams_Pool_Size];

            console.log(arreglo);
        }
    });
    var data = google.visualization.arrayToDataTable([
        ['Componente', 'Cantidad'],
        ['Redo Buffers', parseInt(Redo_Buffers)/1024/1024],
        ['Buffer Cache Size', parseInt(Buffer_Cache_Size)/1024/1024],
        ['Shared Pool Size', parseInt(Shared_Pool_Size)/1024/1024],
        ['Large Pool Size', parseInt(Large_Pool_Size)/1024/1024],
        ['Java Pool Size', parseInt(Java_Pool_Size)/1024/1024],
        ['Streams Pool Size', parseInt(Streams_Pool_Size)/1024/1024]
    ]);

    var options = {
        title: 'Estado del SGA en MB',
        width: 900,
        height: 300,
        hAxis: {minValue: 0,
                    maxValue: 500
                    
            }
    };
   
    var chart = new google.visualization.PieChart(document.getElementById('div_SGA_chart'));
    chart.draw(data, options);
}